<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>更新结果</title>
    <!-- Bootstrap core CSS -->
    <link href="./css/bootstrap.min.css" rel="stylesheet">

    <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
    <!-- <link href="../../assets/css/ie10-viewport-bug-workaround.css" rel="stylesheet"> -->

    <!-- Custom styles for this template -->
    <link href="./css/navbar-fixed-top.css" rel="stylesheet">
    <script type="text/javascript" src="../js/jquery.js"></script>
</head>
<body>

<?php
include '../dbconnect.php';

// 获取内容
$uid = isset($_POST['uid']) ? $_POST['uid'] : '';
$username = isset($_POST['username']) ? $_POST['username'] : '';
$password = isset($_POST['password']) ? $_POST['password'] : '';
$email = isset($_POST['email']) ? $_POST['email'] : '';

if (empty($uid) || empty($username) || empty($password) || empty($email)) {
    echo "所有字段都是必填的！";
    exit;
}

// 使用预处理语句更新数据库
$sql = "UPDATE user SET U_Username = ?, U_Password = ?, U_Email = ? WHERE U_ID = ?";
$stmt = $conn->prepare($sql);
$stmt->bind_param("ssss", $username, $password, $email, $uid);

if ($stmt->execute()) {
    header("Location: userList.php");
    exit;
} else {
    echo "更新失败：" . $stmt->error;
}

$stmt->close();
$conn->close();
?>

</body>
</html>